x86 hvm: Introduce unregister_io_handler
authorKeir Fraser <keir@xen.org>
Fri, 29 Oct 2010 17:14:01 +0000 (18:14 +0100)
committerKeir Fraser <keir@xen.org>
Fri, 29 Oct 2010 17:14:01 +0000 (18:14 +0100)
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Keir Fraser <keir@xen.org>
xen/arch/x86/hvm/intercept.c
xen/include/asm-x86/hvm/io.h

index 4af9e3d112776cb7b3fd074dc24e603837e00914..2d88cc86b02882d8b219421266221a5bc240644c 100644 (file)
@@ -237,13 +237,30 @@ void register_io_handler(
 
     handler->hdl_list[num].addr = addr;
     handler->hdl_list[num].size = size;
-    if ( (handler->hdl_list[num].type = type) == HVM_PORTIO )
-        handler->hdl_list[num].action.portio = action;
-    else
-        handler->hdl_list[num].action.mmio = action;
+    handler->hdl_list[num].action.ptr = action;
     handler->num_slot++;
 }
 
+void unregister_io_handler(
+    struct domain *d, unsigned long addr, unsigned long size, int type)
+{
+    struct hvm_io_handler *handler = &d->arch.hvm_domain.io_handler;
+    int i;
+
+    for ( i = 0; i < handler->num_slot; i++ )
+        if ( (handler->hdl_list[i].addr == addr) &&
+             (handler->hdl_list[i].size == size) &&
+             (handler->hdl_list[i].type == type) )
+            goto found;
+    return;
+
+ found:
+    memcpy(&handler->hdl_list[i],
+           &handler->hdl_list[handler->num_slot-1],
+           sizeof(struct io_handler));
+    handler->num_slot--;
+}
+
 /*
  * Local variables:
  * mode: C
index c10a0bef2afdbee8a8d7d690574a0e48c9394b4d..8a81bff225f24ce50a072220c93cf202e5e0bd77 100644 (file)
@@ -50,6 +50,7 @@ struct io_handler {
     union {
         portio_action_t portio;
         mmio_action_t   mmio;
+        void           *ptr;
     } action;
 };
 
@@ -68,6 +69,8 @@ int hvm_io_intercept(ioreq_t *p, int type);
 void register_io_handler(
     struct domain *d, unsigned long addr, unsigned long size,
     void *action, int type);
+void unregister_io_handler(
+    struct domain *d, unsigned long addr, unsigned long size, int type);
 
 static inline int hvm_portio_intercept(ioreq_t *p)
 {
@@ -89,6 +92,12 @@ static inline void register_portio_handler(
     register_io_handler(d, addr, size, action, HVM_PORTIO);
 }
 
+static inline void unregister_portio_handler(
+    struct domain *d, unsigned long addr, unsigned long size)
+{
+    unregister_io_handler(d, addr, size, HVM_PORTIO);
+}
+
 static inline void register_buffered_io_handler(
     struct domain *d, unsigned long addr,
     unsigned long size, mmio_action_t action)